#include <iostream>

const int size = 10;

class ArrayStack
{
public:
    ArrayStack() : top(0) {}
    void add(int data);
    void cout();
    int *getTop();
    bool isEmpty();

private:
    int Stack[size];
    int top;
};

void ArrayStack::add(int data)
{
    if (top == size)
        std::cout << "栈满了\n";
    else
    {
        Stack[top++] = data;
    }
}

void ArrayStack::cout()
{
    if (top == 0)
    {
        std::cout << "栈空\n";
        return;
    }
    else
    {
        top--;
    }
}

int *ArrayStack::getTop()
{
    if (top == 0)
        return nullptr;
    else
    {
        return Stack + top - 1;
    }
}

bool ArrayStack::isEmpty()
{
    return top == 0;
}

int main()
{
    ArrayStack a;
    for (int i = 0; i < 10; i++)
        a.add(i + 1);

    while (!a.isEmpty())
    {
        std::cout << *a.getTop() << " ";
        a.cout();
    }
    std::cout<<std::endl;
    return 0;
}